﻿using Shop.RemoteModel.Stock.Model;
using Shop.StoreGatewayModular.Interface;
using Shop.StoreGatewayModular.Linq;
using Shop.StoreGatewayModular.Model.Stock;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    /// <summary>
    /// 商品库存
    /// </summary>
    internal class StockApi : ApiController
    {
        private readonly IStockService _Service;

        public StockApi (IStockService service)
        {
            this._Service = service;
        }

        public bool Add (StockAdd param)
        {
            return this._Service.AddSkuStock(param, base.UserState.ToUserId());
        }

        public int GetStockNum ([NumValidate("shop.sku.id.error", 1)] long skuId)
        {
            return this._Service.GetStockNum(skuId);
        }

        public PagingResult<GoodsStockDto> Query (PagingParam<StockQueryParam> query)
        {
            return this._Service.Query(query);
        }
    }
}
